package mytools;

import android.app.Application;
import android.content.Context;
import android.content.SharedPreferences;
import android.preference.PreferenceManager;
import android.util.ArrayMap;

import com.socks.library.KLog;
import com.sxpjyy.monkey.mobilenurse.BuildConfig;

import objects.InPatient;
import objects.Section;
import objects.User;

public class ApplicationUtil extends Application {

    private User user; //登陆用户
    private InPatient inPatient; //选择的病人
    private Section section; //选择的病区

    private long deltaTime = 0;//与服务器时间差
    public static Context applicationContext;

    private SharedPreferences mySharedPreferences;

    private ArrayMap<String, String> deviceInfos;

    @Override
    public void onCreate() {
        super.onCreate();
        KLog.init(BuildConfig.LOG_DEBUG);
        mySharedPreferences = PreferenceManager.getDefaultSharedPreferences(getApplicationContext());
        applicationContext = this;
    }

    public long getDeltaTime() {
        return deltaTime;
    }

    public void setDeltaTime(long deltaTime) {
        this.deltaTime = deltaTime;
    }

    public ArrayMap<String, String> getDeviceInfos() {
        if (deviceInfos == null) {
            return new ArrayMap<>();
        }
        return deviceInfos;

    }

    public void setDeviceInfos(ArrayMap<String, String> deviceInfos) {
        this.deviceInfos = deviceInfos;
    }

    public SharedPreferences getMySharedPreferences() {
        return mySharedPreferences;
    }

    public User getUser() {
        return user;
    }

    public void setUser(User user) {
        this.user = user;
    }

    public InPatient getInPatient() {
        return inPatient;
    }

    public void setInPatient(InPatient inPatient) {
        this.inPatient = inPatient;
    }

    public Section getSection() {
        return section;
    }

    public void setSection(Section section) {
        this.section = section;
    }
}
